package www.lagou.app;

import org.junit.Test;
import www.lagou.dao.AcountDao;
import www.lagou.dao.TransactionDao;
import www.lagou.entity.Transaction;
import www.lagou.utils.DateUtils;

import java.sql.SQLException;

public class AccountDaoTest {
    AcountDao acountDao=new AcountDao();
    TransactionDao transactionDao=new TransactionDao();
    //卡号转账
    //accountCard1: 1122334455   accountCard1: 5544332211
    @Test
    public void testTransferMoney() throws SQLException {
            if (acountDao.transferMoney("1122334455","5544332211",10)) {
                System.out.println("卡号1122334455转账成功向卡号5544332211");
            }else {
                System.out.println("转账失败");
            }
        }
//查询卡号为5544332211的账户余额
    @Test
    public void testGetBalanceFromAccountCard() throws SQLException {
        System.out.println("卡号1122334455的账户余额是："+acountDao.getBalanceFromAccountCard("1122334455"));
        System.out.println("卡号5544332211的账户余额是："+acountDao.getBalanceFromAccountCard("5544332211"));
    }

    //测试 增加交易记录
@Test
public void testAddTransaction() throws SQLException {
    Transaction transaction=new Transaction();
    transaction.setCardid("1122334455");
    transaction.setTratype("转出");
    transaction.setTramoney(300);
    transaction.setTradate(DateUtils.getDateFormart());
    int result=transactionDao.addTransaction(transaction);
    if (result>0){
        System.out.println("交易记录增加成功");
    }else {
        System.out.println("交易记录增加失败");
    }

}


}
